<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>添加角色</title>
  <link rel="stylesheet" href="/static/layui/css/layui.css">
  <link rel="stylesheet" href="/static/admin/css/admin.css">
  <script src="/static/layui/layui.js"></script>
</head>
</body>
<div class="layui-container" style="margin-top: 30px;">
<form class="layui-form">
    <input type="hidden" name="id" value="{$row.id}">
    <div class="layui-form-item">
        <label class="layui-form-label">会场时间</label>
        <div class="layui-input-block">
          <input type="text" name="activity_time" value="{$row.activity_time}" required  lay-verify="required" id="activity-time" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">配置场次</label>
      <input type="hidden" id="session" value="{$row.session}" name="session_values" />
      <div class="layui-input-block">
          <input type="checkbox" name="session_title[]" title="00:00" value="00:00">
          <input type="checkbox" name="session_title[]" title="01:00" value="01:00">
          <input type="checkbox" name="session_title[]" title="02:00" value="02:00">
          <input type="checkbox" name="session_title[]" title="03:00" value="03:00">
          <input type="checkbox" name="session_title[]" title="04:00" value="04:00">
          <input type="checkbox" name="session_title[]" title="05:00" value="05:00">
          <input type="checkbox" name="session_title[]" title="06:00" value="06:00">
          <input type="checkbox" name="session_title[]" title="07:00" value="07:00">
          <input type="checkbox" name="session_title[]" title="08:00" value="08:00">
          <input type="checkbox" name="session_title[]" title="09:00" value="09:00">
          <input type="checkbox" name="session_title[]" title="10:00" value="10:00">
          <input type="checkbox" name="session_title[]" title="11:00" value="11:00">
          <input type="checkbox" name="session_title[]" title="12:00" value="12:00">
          <input type="checkbox" name="session_title[]" title="13:00" value="13:00">
          <input type="checkbox" name="session_title[]" title="14:00" value="14:00">
          <input type="checkbox" name="session_title[]" title="15:00" value="15:00">
          <input type="checkbox" name="session_title[]" title="16:00" value="16:00">
          <input type="checkbox" name="session_title[]" title="17:00" value="17:00">
          <input type="checkbox" name="session_title[]" title="18:00" value="18:00">
          <input type="checkbox" name="session_title[]" title="19:00" value="19:00">
          <input type="checkbox" name="session_title[]" title="20:00" value="20:00">
          <input type="checkbox" name="session_title[]" title="21:00" value="21:00">
          <input type="checkbox" name="session_title[]" title="22:00" value="22:00">
          <input type="checkbox" name="session_title[]" title="23:00" value="23:00">
      </div>
    </div>

    <!-- <div class="layui-form-item">
      <label class="layui-form-label">轮播图片</label>
      <div class="layui-input-block">
        <input type="hidden" name="image_url" id="icon">
        <img src="/static/admin/img/upimg.png" id="upload" class="layui-upimg">
      </div>
    </div> -->
    <div class="layui-form-item">
        <label class="layui-form-label">会场描述</label>
        <div class="layui-input-block">
          <textarea name="desc" placeholder="请输入内容" class="layui-textarea">{$row.desc}</textarea>
        </div>
      </div>
    <div class="layui-form-item">
      <label class="layui-form-label">是否启用</label>
      <div class="layui-input-block">
        <input type="radio" name="status" value="1"  {notempty name="row.status"} checked {/notempty} title="启用">
        <input type="radio" name="status" value="0" {empty name="row.status"} checked {/empty} title="禁用">
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-input-block">
        <button class="layui-btn" lay-submit lay-filter="formAdd">立即提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
      </div>
    </div>
  </form>
</div>
<script>
    //Demo
    layui.use(['form','upload','laydate'], function(){
      var $ = layui.jquery,form = layui.form; laydate = layui.laydate//upload = layui.upload;
      // upload.render({
      //     elem: "#upload",
      //     field: "image",
      //     url: "/admin/upload",
      //     done: function(res){
      //         if(res.code==1){
      //           $('#upload').attr('src',res.src)
      //           $('#icon').val(res.src);
      //         }
      //     }
      // });

      laydate.render({
        elem: '#activity-time',
        min:0
      });

      $(document).ready(function(){
        let arr =  JSON.parse($('#session').val());
        let checkbox =  $('input[name="session_title[]"]');
          checkbox.each(function(){
              let val = $(this).val();
              let index = arr.indexOf(val);
              if(index != -1){
                $(this).prop('checked',true);
              }
          });
          form.render('checkbox');
      });

    
     

      form.on('submit(formAdd)',function(data){
          $.post('/store/spike/meeting/update',data.field,function(res){
                if(res.code ==1 ){
                  let index =  parent.layer.getFrameIndex(window.name);
                  parent.layer.close(index);
                  parent.$.pjax.reload('#main',{fragment: '#main'});
                }

                return layer.msg(res.msg,{icon:2});
          });

          return false;
      });
     
    });
    </script>
</body>
</html>